/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import AO.Faculty;
import dbconnector.DBDriver;
import java.io.File;
import java.io.FileInputStream;
import java.sql.PreparedStatement;


/**
 *
 * @author FRIENDS
 */
public class FacultyDAO 
{

    
     public static boolean save(Faculty f) throws Exception
  {
    try
    {
        {
            File file=new File("D:/faculty.png");
            System.out.println(file.getCanonicalPath());
//byte[] dataBytes=getBytesFromFile(file);
FileInputStream fis=new FileInputStream(file);
 // String bytes = new String(dataBytes);

      PreparedStatement pstmt = DBDriver.getPrepare("insert into faculty values(?,?,?,?,?,?,?,?,?,?,?)");
      pstmt.setString(1, f.getUserid());
      pstmt.setString(2, f.getPassword());
      pstmt.setString(3, f.getFname());
      pstmt.setString(4, f.getLname());
      pstmt.setString(5, f.getQualification());
      pstmt.setString(6, f.getEmail());
      pstmt.setString(7, f.getMobile());
      pstmt.setString(8, f.getGender());
      pstmt.setBinaryStream(9, fis, (int)file.length());
      pstmt.setDouble(10, Double.parseDouble(f.getExperiance()));
      pstmt.setInt(11, Integer.parseInt(f.getSalary()));
      
      
      
      int i=pstmt.executeUpdate();
      if(i==1)
          return true;
    }
    
    
  }
     catch (Exception e) {
         e.printStackTrace();
        return false;
    }
    return false;
  }
     
     
     

}
